package hn.cch.advanced.thread;

public class ThreadRunnable {

    public static void main(String[] args) {
        run();
    }

    public static void run() {
        // 运行的是Thread类的run方法，而不是Runnable接口的run方法
        new Thread(new Runnable() {
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("Runnable=" + Thread.currentThread().getName());
                }
            }
        }) {
            @Override
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("Thread=" + Thread.currentThread().getName());
                }
            }
        }.start();
    }

}

